package com.zking.controller.dwm;

import com.zking.entity.Address;
import com.zking.entity.Cart;
import com.zking.service.dwm.AddRessService_dwm;
import com.zking.service.dwm.CartService_dwm;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;

import javax.servlet.http.HttpServletRequest;
import java.util.ArrayList;
import java.util.List;

@Controller
@RequestMapping(value = "/getOrder")
public class getOrderInfoController_dwm {

    @Autowired
    private AddRessService_dwm addRessService_dwm;

    @Autowired
    private CartService_dwm cartService_dwm;

    @RequestMapping(value = "/select")
    public String selec(String[] arr,HttpServletRequest request){
        List<Cart> carts = new ArrayList<>();
        for (int i=0;i<arr.length;i++){
            carts.add(cartService_dwm.selectCartid(arr[i]));
        }
        String name = request.getParameter("name");
        request.setAttribute("carts",carts);
        request.setAttribute("nameId",name);
        request.setAttribute("address",addRessService_dwm.selectAddRess(name));
        return "dwm/getOrderInfo";
    }

}
